package view {
	import flash.display.BitmapData;
	import flash.display.GradientType;
	import flash.display.Sprite;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import model.Player;
	
	/**
	 * ...
	 * @author flyingSnow
	 */
	public final class TabButton extends Sprite implements IPlayerView{
		private var _colorIndex:int;
		private var _tfScore:TextField;
		private var _bgLayer:Sprite;
		
		public function TabButton(colorIndex:int) {
			this._colorIndex = colorIndex;
			drawFrames();
		}
		
		/* INTERFACE view.IPlayerView */
		
		public function update(player:Player):void {
			score = player.score+"";
		}
		
		private function drawFrames():void {
			_bgLayer = new Sprite();
			_bgLayer.graphics.lineStyle(2,0x9E9E9E,0.8);
			
			_bgLayer.graphics.beginFill(Square.COLORS[_colorIndex]);
			_bgLayer.graphics.drawCircle(0, 0, 25);			
			_bgLayer.graphics.endFill();
			
			addChild(_bgLayer);
			
			_tfScore = new TextField();
			_tfScore.selectable = false;
			//_tfScore.border = true;
			_tfScore.defaultTextFormat = new TextFormat("Comic Sans MS", 22, 0xffffff);
			_tfScore.autoSize = TextFieldAutoSize.CENTER;
			_tfScore.text = "";
			_tfScore.y = -17;
			_tfScore.x = -2;
			_tfScore.filters = [new GlowFilter(0,0.5,4,4,1)];
			addChild(_tfScore);
		}
		
		public function set score(value:String):void {
			_tfScore.text = value;
		}
		
		
	}

}